#ifndef _LOGIN_AUTHORITY_TASK_H_
#define _LOGIN_AUTHORITY_TASK_H_

#include <qbmessage/include/message_bond.h>
#include <qbprotocol/include/rdProto.h>

#include <memory>
#include <set>

#include "task.h"

namespace qb {
// 登录到LoginServer进行验证的任务
class CLoginAuthorityTask : public CTask, public IQpidMessageProcessor {
 public:
  CLoginAuthorityTask();
  ~CLoginAuthorityTask();

  void RequestUserPermission();
  void RequestCDCAuthority();
  void RequestCSIAuthority();
  void setDictReady();

 protected:
  virtual void StartImpl();
  virtual void TerminateImpl();
  virtual bool IsConnectTask() { return false; }
  virtual void OnNetData(char* pRecvData, int nDataLen) {}
  virtual void OnNetStatus(int32_t status) {}
  virtual int32_t GetTaskTimeout() { return LOGIN_AUTHORITY_TIMEOUT; }
  void OnTimeout() override;

  void taskFinish();
  void AuthorityTaskFinish(_eFunID_t funcid);
  STDMETHOD_(void, OnResponse)(THIS_ int32_t funcId, const SSAckMsg&);

 private:
  std::set<_eFunID_t> m_setAuthority;
  std::shared_ptr<CLoginAuthorityTask> m_ptr = nullptr;
  bool m_dictReady = false;
};
}  // namespace qb

#endif
